package com.fourhats.model;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@NamedNativeQueries({
	@NamedNativeQuery(
		name = "getNearbyPlaces",
		query = "CALL sp_getNearbyPlaces(:lat, :lng, :dist, :min_lat, :max_lat, :min_lng, :max_lng)",
		resultClass = Place.class
	)
})

@Entity
@Table(name="place")
public class Place extends com.fourhats.model.Entity {
	
	@Column(name="name")
	private String name;
	
	@Column(name="description")
	private String description;
	
	@Column(name="creationDate")
	private Date creationDate;
	
	@OneToMany(mappedBy="place")
    private Set<Price> prices;
	
	@Column(name="address")
	private String address;

	@Column(name="enable")
	private boolean enable;
	
	@ManyToOne
    @JoinColumn(name="placeTypeId")
	private PlaceType placeType;
	
	@ManyToOne
    @JoinColumn(name="cityId")
	private City city;
	
	@Column(name="latitude")
	private BigDecimal latitude;
	
	@Column(name="longitude")
	private BigDecimal longitude;
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	public Date getCreationDate() {
		return creationDate;
	}
	
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}
	
	public String getAddress() {
		return address;
	}
	
	public void setAddress(String address) {
		this.address = address;
	}
	
	public boolean isEnable() {
		return enable;
	}
	
	public void setEnable(boolean enable) {
		this.enable = enable;
	}
	
	public PlaceType getPlaceType() {
		return placeType;
	}
	
	public void setPlaceType(PlaceType placeType) {
		this.placeType = placeType;
	}
	
	public City getCity() {
		return city;
	}
	
	public void setCity(City city) {
		this.city = city;
	}
	
	public Set<Price> getPrices() {
		return prices;
	}
	
	public void setPrices(Set<Price> prices) {
		this.prices = prices;
	}

	public BigDecimal getLatitude() {
		return latitude;
	}

	public void setLatitude(BigDecimal latitude) {
		this.latitude = latitude;
	}

	public BigDecimal getLongitude() {
		return longitude;
	}

	public void setLongitude(BigDecimal longitude) {
		this.longitude = longitude;
	}
}
